/**
 * Copyright ©2016-2020 northkingbpo Corporation, All Rights Reserved
 * http://www.northkingbpo.net/
 */
package profile.hujia.algorithm.common;

import lombok.extern.slf4j.Slf4j;

/**
 * class info
 *
 * @author hujia
 * @date 2019-02-15 10:21
 */
@Slf4j
public class CommonFunction {

    public static void showTwoDimensional(int[][] array, String title) {
        log.info(title);
        StringBuilder str = new StringBuilder();
        for (int i = 0; i < array.length; ++i) {
            str.delete(0, str.length());
            for (int j = 0; j < array[i].length; ++j) {
                str.append(array[i][j]);
                str.append(",");
            }
            if (str.length() > 0) {
                log.info((i + 1)+":" + str.substring(0, str.length() - 1));
            } else {
                log.info("null");
            }
        }
    }

    public static void showOneDimensional(int[] array, String title) {
        log.info(title);
        StringBuilder str = new StringBuilder();
        for (int i = 0; i < array.length; ++i) {
            str.append(array[i]);
            str.append(",");
        }
        if (str.length() > 0) {
            log.info(str.substring(0, str.length() - 1));
        } else {
            log.info("null");
        }
    }
}
